<#assign ctrl_base_name = "DataViewExpBarControlBase"/>
<#assign import_block>
import CodeListService from "@service/app/codelist-service";
<#if view.getPSSysCounterRef?? && view.getPSSysCounterRef()?? && view.getPSSysCounterRef().getPSAppCounter()??>
<#assign appCounter = view.getPSSysCounterRef().getPSAppCounter() />
import  ${srfclassname('${appCounter.getCodeName()}')}CounterService  from '@/counter/${srffilepath2(appCounter.getCodeName())}/${srffilepath2(appCounter.getCodeName())}-counter';
</#if>
</#assign>

<#ibizinclude>
../@MACRO/CONTROL/CONTROL_HEADER-BASE.vue.ftl
</#ibizinclude>
<#ibizinclude>
../@MACRO/FUNC/MACRO.ftl
</#ibizinclude>
<#if ctrl.getPSControls()??>
    <#assign controls = ctrl.getPSControls()/>
    <#list controls as singleControl>
        <#if singleControl.getControlType() == "TOOLBAR">

    ${P.getCtrlCode(singleControl, 'CONTROL.vue').code}
        </#if>
    </#list>
</#if>
<#ibizinclude>
../@MACRO/CONTROL/EXP_CONTROL_CONTENT_BASE.vue.ftl
</#ibizinclude>
<#if view.isEnableQuickGroup()>

    /**
     * 加载快速分组模型
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */
    public loadQuickGroupModel(){
        this.$nextTick(() => {
            <#if view.getQuickGroupPSCodeList()??>
            <#assign codelist=view.getQuickGroupPSCodeList() />
            let quickGroupCodeList:any = {tag:'${codelist.codeName}',codelistType:'${codelist.getCodeListType()}'};
            if(quickGroupCodeList.tag && Object.is(quickGroupCodeList.codelistType,"STATIC")){
                const codelist = this.$store.getters.getCodeList(quickGroupCodeList.tag);
                if (codelist) {
                    this.quickGroupModel = [...this.handleDynamicData(JSON.parse(JSON.stringify(codelist.items)))];
                } else {
                    <#noparse>console.log(`----${quickGroupCodeList.tag}----代码表不存在`);</#noparse>
                }
            }else if(quickGroupCodeList.tag && Object.is(quickGroupCodeList.codelistType,"DYNAMIC")){
                this.codeListService.getItems(quickGroupCodeList.tag,{},{}).then((res:any) => {
                    this.quickGroupModel = res;
                }).catch((error:any) => {
                    <#noparse>console.log(`----${quickGroupCodeList.tag}----代码表不存在`);</#noparse>
                });
            }
            </#if>
        });
    }
</#if>

    /**
     * 卡片视图导航选中
     *
     * @param {any []} args
     * @param {string} [tag]
     * @param {*} [$event2]
     * @returns {void}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public ${ctrl.name}_selectionchange(args: any [], tag?: string, $event2?: any): void {
        let tempContext:any = {};
        let tempViewParam:any = {};
        if (args.length === 0) {
            this.selection = {};
            <#if expbarToolbar??>
            this.calcToolbarItemState(true);
            </#if>
            return ;
        }
        const arg:any = args[0];
        if(this.context){
            Object.assign(tempContext,JSON.parse(JSON.stringify(this.context)));
        }
        <#if ctrl.getXDataPSControl()??>
        <#assign xDataControl = ctrl.getXDataPSControl()/>
        <#if xDataControl.getPSAppDataEntity()??>
        <#assign curDataEntity = xDataControl.getPSAppDataEntity()/>
        Object.assign(tempContext,{'${curDataEntity.getCodeName()?lower_case}':arg['${curDataEntity.getCodeName()?lower_case}']});
        Object.assign(tempContext,{srfparentdename:'${curDataEntity.getCodeName()}',srfparentkey:arg['${curDataEntity.getCodeName()?lower_case}']});
        if(this.navFilter && !Object.is(this.navFilter,"")){
            Object.assign(tempViewParam,{[this.navFilter]:arg['${curDataEntity.getCodeName()?lower_case}']});
        }
        if(this.navPSDer && !Object.is(this.navPSDer,"")){
            Object.assign(tempViewParam,{[this.navPSDer]:arg['${curDataEntity.getCodeName()?lower_case}']});
        }
        </#if>
        </#if>
        if(this.navigateContext && Object.keys(this.navigateContext).length >0){
            let _context:any = this.$util.computedNavData(arg,tempContext,tempViewParam,this.navigateContext);
            Object.assign(tempContext,_context);
        }
        if(this.navigateParams && Object.keys(this.navigateParams).length >0){
            let _params:any = this.$util.computedNavData(arg,tempContext,tempViewParam,this.navigateParams);
            Object.assign(tempViewParam,_params);
        }
        
        <#if xDataControl?? && xDataControl.getNavPSAppView()?? && xDataControl.getNavPSAppView().getViewType() == "DEREDIRECTVIEW">
        this.appUIService.getService('${xDataControl.getNavPSAppView().getPSAppDataEntity().getCodeName()?lower_case}').then((service) => {
            if(!service) {
                this.$Notice.error({desc: '重定向服务不存在！'})
                return;
            }
            let srfkey:any = tempContext.${xDataControl.getNavPSAppView().getPSAppDataEntity().getCodeName()?lower_case}
            service.getRDAppView(srfkey,false).then((res:any) =>{
                if(res && res.viewname && res.srfappde){
                    this.selection = {};
                    Object.assign(this.selection, { view: { viewname: res.component },context:tempContext,viewparam:tempViewParam});
                    this.$forceUpdate();
                }else{
                    console.error("未查找到重定向视图")
                }
            })
        })
        <#else>
        this.selection = {};
        Object.assign(this.selection, { view: { viewname: this.navViewName },context:tempContext,viewparam:tempViewParam});
        <#if expbarToolbar??>
        this.calcToolbarItemState(false);
        </#if>
        this.$forceUpdate();
        </#if>
    }
<#ibizinclude>
../@MACRO/CONTROL/CONTROL_BOTTOM-BASE.vue.ftl
</#ibizinclude>